
package cz.muni.fi.pa165.hauntedhouses.dao;

import cz.muni.fi.pa165.hauntedhouses.entity.House;
import cz.muni.fi.pa165.hauntedhouses.entity.Human;
import java.util.List;

/**An interface for Human Entity. Provides basic CRUD operations along with some findBy methods.
 *
 * @author Jan Vyhnanek (374138)
 */
public interface HumanDAO {
    
    /**Checks for parameter correctness and stores the Human to the DB.
     *
     * @param human Human we want to store in the DB
     * @throws IllegalArgumentException if parameter itself or any of its attributes
     * is null or, in case of strings, empty. Also throws this exception if ID is already assigned.
     */
    void create(Human human);
    
    /**Checks for parameter correctness and existence of give Human in the DB.
     * Then it updates the human in the DB.
     *
     * @param human Human we want to update in the DB
     * @throws IllegalArgumentException if parameter itself or any of its attributes
     * is null or, in case of strings, empty.
     */
    void update(Human human);
    
    /**Checks for parameter correctness and existence in the DB. If its ok, given 
     * Human will be erased from DB.
     *
     * @param human Human we want to remove from the DB
     * @throws IllegalArgumentException if parameter itself or any of its attributes
     * is null or, in case of strings, empty.
     */
    void remove(Human human);
    
    /**Returns a Human from the DB based on its ID. If there is no such Human, null is returned.
     *
     * @param id id of the Human we want to find in the DB
     * @return Human object or null if there is no Human with given ID
     * @throws IllegalArgumentException if id is null or < 0
     */
    Human get(Long id);
    
    /**Returns a list of all Humans from the DB.
     *
     * @return A list of all Humans in the DB. Empty list if there are none.
     */
    List<Human> findAll();
    
    /**Returns a list of all Humans based of their names or part of their names
     *
     * @param name name of part if the name, based on which we want to search for Human
     * @return List of a matching Humans or empty list
     * @throws IllegalArgumentException if given string is null or empty
     */
    List<Human> findByName(String name);
    
    /**Returns a list of Humans based on their House attribute.
     *
     * @param house House, whose inhibitants we search for.
     * @return List of all ppl living in given House.
     * @throws IllegalArgumentException if parameter itself or any of its attributes
     * is null or, in case of strings, empty.
     */
    List<Human> findByHouse(House house);
}
